home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / ms_dos / cd_lib / src / cdr_stat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-08  |  1.0 KB  |  47 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4. #include "define.h"
  5.  
  6. /* ドライブステータス情報の読み取り */
  7. /*
  8.  * decice_no: device number (Towns CD-ROM -> 0)
  9.  * return: 0 -> 正常終了, 0以外 -> エラー
  10.  *           sector_size <- 2048 , 2336 or 2340 (sector size)
  11.  *           sector_max <- 最大論理セクタ数
  12.  */
  13. int cdr_status(int device_no, int *sector_size, long int *sector_max)
  14. {
  15.     union REGS reg;
  16.     
  17.     reg.h.ah = 0x02;
  18.     reg.h.al = (0xC0 | (u_char) device_no);
  19.     reg.h.ch = 0x00;
  20.     
  21.     int86(0x93, ®, ®);
  22.     
  23.     if (sector_max) {
  24.         *sector_max = (u_long) reg.h.bl << 16;
  25.         *sector_max += reg.x.dx;
  26.     }
  27.     
  28.     if (sector_size) {
  29.         if (reg.h.al == 0x04) {
  30.             *sector_size = 2048;
  31.         } else if (reg.h.al == 0x08) {
  32.             *sector_size = 2336;
  33.         } else {
  34.             *sector_size = 2340; /* (reg.h.al == 0x09) のはず */
  35.         }
  36.     }
  37.     
  38.     if (reg.h.ah == 0) {
  39.         return 0;
  40.     } else if (reg.h.ah == 0x02) {  /* device number error */
  41.         return DEVERR;
  42.     } else {                        /* (reg.h.ah == 0x80) hard ware error */
  43.         return reg.x.cx;
  44.     }
  45. }
  46.  
  47.